<?php
/**
 * Created by PhpStorm.
 * User: xf
 * Date: 2018/5/30
 * Time: 15:27
 */

namespace App\Http\Middleware;
use Illuminate\Support\Facades\Cache;
use Closure;

class Login
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next, $guard = null)
    {
        //return $next($request);
        // 判断后台是否登录
        if (Cache::has('user')) {
            return $next($request);
        } else {
            return redirect('api/user/reLogin');
        }


    }
}